package com.chao.mail.api.http

import com.chao.mail.api.dto.MailSendMessage
import com.chao.mail.api.dto.MailSendResponse
import com.chao.mail.application.MailApplicationService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

/**
 * REST服务端点
 * @author zhangchao
 */
@RestController
@RequestMapping("mail")
class MailCenterController {
    @Autowired
    lateinit var mailApplicationService: MailApplicationService

    @PostMapping("sending")
    fun sendMail(@RequestBody mailSendMessage: MailSendMessage): HttpResponse<MailSendResponse> {
        val response = mailApplicationService.sendMail(mailSendMessage)
        return HttpResponse(HttpResponse.SUCCESS, response)
    }
}
